var fs = require('fs')
var express = require('express')
// var qs = require('querystring')
var app = express()
var all = fs.readFileSync('./daa.json')
all = all.toString()
all = JSON.parse(all)
// console.log(all);

app.use(express.json())// 中间件，用于解析JSON请求体

app.use((req, res, next) => {
  res.setHeader("Content-Type", "text/html; charset=utf-8")
  res.setHeader("Access-Control-Allow-Origin", "*")
  next()
})

// 获取所有数据
app.get("/userll", function (req, res) {
  res.json({
    code: 0,
    msg: "获取所有数据成功",
    data: all
  })
})
// 3启动 web 服务器
app.listen(3000, () => {
  console.log('启动服务；http://127.0.0.1:3000')
})

